<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="disabled">
      <a-form-model layout="horizontal" ref="subForm" slot="detail" :model="model" :rules="validatorRules" v-bind="formItemLayout">
        <z-form-item :datas="fieldArr" :form="model" :rules="validatorRules" :gutter="0">
          <!--//自定义姓名-->
          <template slot="slots-name"> 小松鼠 </template>
          <!--//自定义身份证-->
          <template slot="slots-incidentCode"> 46000xxxxxxxxxxxxx </template>
        </z-form-item>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
  export default {
    props: {
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model: {},
        confirmLoading: false,
        formItemLayout: {
          labelCol: { span: 6 },
          wrapperCol: { span: 16 }
        },
        fieldArr: [
          {label: '姓名', prop: 'name'},
          {label: '身份证', prop: 'incidentCode'},
          {label: '人员类型', prop: 'sex', tagType: 'dict-select', dictCode:'sex'},
          {label: '证明材料', prop: 'cl', tagType: 'upload-file'},
        ],
        validatorRules: {
          suspectAccountNumber:[ { required: true, message: '请选择状态!' }],
          transferTime:[ { required: true, message: '请选择签到类型!' }],
          phone:[ { required: true, message: '请填入手机号码!' },]
        }
      }
    },
    methods: {
      show (record) {
        this.model = record?Object.assign({}, record):this.model;
      },
      submitForm () {
        const parameter = Object.assign({}, this.model)
        this.$refs.subForm.validate((valid)=> {
          if (valid) {
            // warningApi
            //   .dissuadeMsg(parameter)
            //   .then(res => {
            //     this.confirmLoading = false
            //     if (res.success) {
            //       this.$message.success(res.message)
            //       this.$emit('ok');
            //     } else {
            //       this.$message.warn(res.message)
            //     }
            //   })
            //   .catch(e => {
            //     this.$message.warn('请求失败！')
            //     this.confirmLoading = false
            //   })
          } else {
            console.log('error submit!!')
            return false
          }
        })
      }
    }
  }
</script>
